package org.example.springbootdemo02.mapper;



import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.springbootdemo02.pojo.Account;

import java.util.List;

@Mapper
//操作账户Account类的持久层接口
public interface AccountMapper {
    /**
     * 查询所有账户
     * @return
     */
    @Select ("select * from account")
    List<Account> selectAll();
    /**
     * 添加账户
     * @param account
     */
    void insert(Account account);

    /**
     * 根据id删除账户
     * @param id
     */
    @Delete ("delete from account where id=#{id}")
    void delete(Integer id);

    /**
     * 根据id修改账户
     * @param account
     */
    void update(Account account);
    /**
     * 根据id查询账户
     * @param id
     * @return
     */
    @Select("select * from account where id=#{id}")
    Account selectById(Integer id);

    /**
     * 根据账户名称查询账户
     * @param name
     * @return
     */
    @Select("select * from account where name=#{name}")
    Account selectByName(String name);
}
